<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>wildcard 查询 | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'query-dsl-wildcard-query.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/query-dsl-wildcard-query.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/query-dsl-wildcard-query.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/query-dsl-wildcard-query.html" rel="nofollow" target="_blank">../en/query-dsl-wildcard-query.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch 权威指南 [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="query-dsl.html">查询领域特定语言(Query DSL)</a></span>
»
<span class="breadcrumb-link"><a href="term-level-queries.html">词级查询</a></span>
»
<span class="breadcrumb-node">wildcard 查询</span>
</div>
<div class="navheader">
<span class="prev">
<a href="query-dsl-type-query.html">« type 查询</a>
</span>
<span class="next">
<a href2="query-dsl-minimum-should-match.html"><code class="literal">minimum_should_match</code> parameter »</a>
</span>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="query-dsl-wildcard-query"></a>通配符查询(wildcard query)
</h2>
</div></div></div>

<p>返回包含匹配通配符模式的词项的文档。</p>
<p>
通配符运算符是匹配一个或多个字符的占位符。

例如，<code class="literal">*</code>通配符运算符匹配零个或多个字符。

可以将通配符运算符与其他字符组合起来创建通配符模式。
</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="wildcard-query-ex-request"></a>请求示例
</h3>
</div></div></div>
<p>
下面这个搜索返回<code class="literal">user</code>字段包含以 <code class="word">ki</code> 开头并以 <code class="word">y</code> 结尾的词的文档。

这些匹配的词项可以包括<code class="word">kiy</code>、<code class="word">kity</code> 或 <code class="word">kimchy</code>。
</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /_search
{
    "query": {
        "wildcard": {
            "user": {
                "value": "ki*y",
                "boost": 1.0,
                "rewrite": "constant_score"
            }
        }
    }
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/302.console"></div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="wildcard-top-level-params"></a><code class="literal">wildcard</code>的顶级参数
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">&lt;field&gt;</code>
</span>
</dt>
<dd>
(必需, object) 你想要搜索的字段。
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="wildcard-query-field-params"></a><code class="literal">&lt;field&gt;</code>的参数
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">value</code>
</span>
</dt>
<dd>
<p>
(必需, string) 你想在指定的 <code class="literal">&lt;field&gt;</code>中查找的词项的通配符模式。
</p>
<p>此参数支持两个通配符运算符：</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<code class="literal">?</code>，它匹配任何单个字符
</li>
<li class="listitem">
<code class="literal">*</code>,，可以匹配零个或多个字符，包括一个空字符
</li>
</ul>
</div>
<div class="warning admon">
<div class="icon"></div>
<div class="admon_content">
<p>
避免模式以 <code class="literal">*</code> 或 <code class="literal">?</code>开头。

这可能会增加查找匹配项所需的迭代次数，并降低搜索性能。 
</p>
</div>
</div>
</dd>
<dt>
<span class="term">
<code class="literal">boost</code>
</span>
</dt>
<dd>
<p>(可选, float) 用于降低或增加查询的<a class="xref" href="query-filter-context.html#relevance-scores" title="相关性评分">相关性评分</a>的浮点数。默认为 <code class="literal">1.0</code>。</p>
<p>
你可以使用 <code class="literal">boost</code> 参数来调整包含两个或更多查询的搜索的相关性评分。
</p>
<p>
<code class="literal">boost</code> 值是相对于默认值 <code class="literal">1.0</code> 的。
其值在 <code class="literal">0</code> 和 <code class="literal">1.0</code> 之间时会降低相关性评分，而大于 <code class="literal">1.0</code> 时会增加相关性评分。
</p>
</dd>
<dt>
<span class="term">
<code class="literal">rewrite</code>
</span>
</dt>
<dd>
(可选, string) 用于重写查询的方法。有效值及更多信息请参考 <a class="xref" href="query-dsl-multi-term-rewrite.html" title="rewrite 参数" rel="nofollow"><code class="literal">rewrite</code> 参数</a>。
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="_notes_7"></a>注意
</h3>
</div></div></div>
<div class="section">
<div class="titlepage"><div><div>
<h4 class="title">
<a id="_allow_expensive_queries_7"></a>允许昂贵的查询
</h4>
</div></div></div>
<p>
如果<a class="xref" href="query-dsl.html#query-dsl-allow-expensive-queries"><code class="literal">search.allow_expensive_queries</code></a>设置为<code class="literal">false</code>，则通配符查询不会被执行。
</p>
</div>

</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="query-dsl-type-query.html">« type 查询</a>
</span>
<span class="next">
<a href2="query-dsl-minimum-should-match.html"><code class="literal">minimum_should_match</code> parameter »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>